﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Panopticon
{
    public static class Globals
    {
        public static float buffer = .1f;
        public static bool debugging = true;
    }

    public static class World
    {
        public static Vector2 relativeVector = Vector2.Zero;
        public static Rectangle Bounds = new Rectangle(50, 50, 1000, 500);
        public static Rectangle drawBounds
        {
            get
            {
                Rectangle db = new Rectangle(Bounds.X - (int)relativeVector.X, Bounds.Y-(int)relativeVector.Y, Bounds.Width, Bounds.Height);
                
                return db;

            }
        }
        public static Vector2 gravity = new Vector2(0f, .1f);
        public static float terminalVelocity= 3f;
    }

    public static class Is
    {
        public static bool keyDown(Keys key)
        {
            return Keyboard.GetState().IsKeyDown(key);
        }
        public static int stripFat = 5;
        //returns a strip of the rectangle that runs along the bottom but doesn't touch the sides
        public static Rectangle buttSpace(Rectangle rectangle, int buffer)
        {
            return new Rectangle(rectangle.Left + buffer, rectangle.Bottom - stripFat, rectangle.Width - (buffer * 2), stripFat); 
        }
        //runs along the top but doesn't touch the sides
        public static Rectangle headSpace(Rectangle rectangle, int buffer)
        {
            return new Rectangle(rectangle.Left + buffer, rectangle.Top, rectangle.Width - (buffer * 2), stripFat);
        }
        //runs along the left but doesn't touch the top or bottom
        public static Rectangle leftSpace(Rectangle rectangle, int buffer)
        {
            return new Rectangle(rectangle.Left, rectangle.Top + buffer, stripFat, rectangle.Height - (buffer * 2));
        }
        //runs along the right but doesn't touch the top or bottom
        public static Rectangle rightSpace(Rectangle rectangle, int buffer)
        {
            return new Rectangle(rectangle.Right - stripFat, rectangle.Top + buffer, stripFat, rectangle.Height - (buffer * 2));
        }

    }
    public static class R //Single instance of a Random used across entire game
    {
        public static Random andy = new Random();

        public static int andom(int minValue, int maxValue)
        { return andy.Next(minValue, maxValue); }
        public static int andom(int maxValue)
        { return andy.Next(maxValue); }
        public static int andom()
        { return andy.Next(); }

        public static float andomFloat(float minValue, float maxValue)
        { return (float)andomDouble(minValue, maxValue); }
        public static float andomFloat(float maxValue)
        { return (float)andomDouble(maxValue); }
        public static float andomFloat()
        { return (float)andomDouble(); }

        public static double andomDouble(double minValue, double maxValue)
        { return minValue + (andy.NextDouble() * (maxValue - minValue)); }
        public static double andomDouble(double maxValue)
        { return andy.NextDouble() * maxValue; }
        public static double andomDouble()
        { return andy.NextDouble(); }
    }
}
